package testHutools.testNumberUtil;

import cn.hutool.core.util.NumberUtil;
import org.junit.Test;

/**
 * @author keyer
 * @Name : hutools.numberUtils.WebsocketTest
 * @Description : 描述
 * Created by cyd on 2021-07-13 09:02:39
 */
public class Tester {

    /**
     * 计算百分比，不带百分号
     */
    @Test
    public void test() {
        double temple = NumberUtil.div((double) 51, (double) 99, 4);
        double overPercent = NumberUtil.mul(temple, 100d);
        System.out.println(overPercent);
    }

    /**
     * 计算百分比，带百分号
     */
    @Test
    public void test02() {
        double count = 51;
        double total = 103;
        double percent = NumberUtil.div(count, total, 4);
        String s = NumberUtil.decimalFormat("#.####%", percent);
        System.out.println(s);
    }

}
